/*
 * Copyright (C) 2014 Realtek Semiconductor Corp.
 * All Rights Reserved.
 *
 * This program is the proprietary software of Realtek Semiconductor
 * Corporation and/or its licensors, and only be used, duplicated,
 * modified or distributed under the authorized license from Realtek.
 *
 * ANY USE OF THE SOFTWARE OTHER THAN AS AUTHORIZED UNDER
 * THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
 *
 */


#include "app_basic.h"

MIB_TABLE_INFO_T gMibVoiceServiceProfileTableInfo;
MIB_ATTR_INFO_T  gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_ATTR_NUM];
MIB_TABLE_VOICESERVICEPROFILE_T gMibVoiceServiceProfileDefRow;
MIB_TABLE_OPER_T gMibVoiceServiceProfileOper;

GOS_ERROR_CODE VoiceServiceProfileDrvCfg(void* pOldRow, void* pNewRow, MIB_OPERA_TYPE operationType, MIB_ATTRS_SET attrSet, UINT32 pri)
{
	//MIB_TABLE_INDEX     tableIndex = MIB_TABLE_VOICESERVICEPROFILE_INDEX;
	//MIB_TABLE_VOICESERVICEPROFILE_T *pMibVoiceServiceProfile;

    OMCI_LOG(OMCI_LOG_LEVEL_DBG, "Start %s...", __FUNCTION__);

    // read out the instanceID
	//pMibVoiceServiceProfile= (MIB_TABLE_VOICESERVICEPROFILE_T*)pNewRow;

    #if 0
    INT32 i;

	UINT32 chid;
	UINT32 proxy = 0;
	UINT32 size=0;
   	mibVoiceServiceProfile.EntityId = pMibVoiceServiceProfile->EntityId;
	const UINT32 entity_id = pMibVoiceServiceProfile->EntityId;

	// VoIP voice CTP 9.9.4
	MIB_TABLE_VOIPVOICECTP_T mibVoIPVoiceCtp, *pMibVoIPVoiceCtp;

	// find channel id
	size = sizeof(MIB_TABLE_VOIPVOICECTP_T);

	if((MIB_GetFirst(MIB_TABLE_VOIPVOICECTP_INDEX, &mibVoIPVoiceCtp , size))==GOS_OK){
		if( mibVoIPVoiceCtp.VOIPMediaProfilePointer == pMibVoiceServiceProfile->EntityId ){
			chid = mibVoIPVoiceCtp.PPTPPointer;
		}
		while( (MIB_GetNext(MIB_TABLE_VOIPVOICECTP_INDEX, &mibVoIPVoiceCtp , size))==GOS_OK ){
			if( mibVoIPVoiceCtp.VOIPMediaProfilePointer == pMibVoiceServiceProfile->EntityId ){
				chid = mibVoIPVoiceCtp.PPTPPointer;
			}
		}
	}
	else{
		ODBG_R("find chid wrong\n");
	}

	// check channel id
	if( chid > gInfo.devCapabilities.potsPortNum ){
		ODBG_R("find chid wrong. chid = %u\n" , chid);
		return GOS_FAIL;
	}
	else{
		ODBG_Y("chid = %u\n" , chid);
	}

	voipCfgPortParam_t *pCfgPort = NULL;
	pCfgPort = &g_pShareCfgVoIP->ports[chid];	// assign config pointer
    #endif
    switch (operationType){
    case MIB_ADD:
    	OMCI_LOG(OMCI_LOG_LEVEL_DBG,"VoiceServiceProfile --> ADD");
    	break;
    case MIB_SET:
    	OMCI_LOG(OMCI_LOG_LEVEL_DBG,"VoiceServiceProfile --> SET");
    	break;
        #if 0
    case MIB_GET:
    	OMCI_LOG(OMCI_LOG_LEVEL_DBG,"VoiceServiceProfile --> GET");
		MIB_Get(tableIndex, &mibVoiceServiceProfile, sizeof(mibVoiceServiceProfile));

		if (MIB_IsInAttrSet(&attrSet , MIB_TABLE_VOICESERVICEPROFILE_ENTITYID_INDEX))
		{
			mibVoiceServiceProfile.EntityId = pMibVoiceServiceProfile->EntityId;
		}

		if (MIB_IsInAttrSet(&attrSet , MIB_TABLE_VOICESERVICEPROFILE_ANNOUNCEMENTTYPE_INDEX))
		{
			mibVoiceServiceProfile.AnnouncementType = 0x3;  //RTK call manager use busy tone.
			//mibVoiceServiceProfile.AnnouncementType = pMibVoiceServiceProfile->AnnouncementType;
		}

		if (MIB_IsInAttrSet(&attrSet , MIB_TABLE_VOICESERVICEPROFILE_ECHOCANCELIND_INDEX))
		{
			mibVoiceServiceProfile.EchoCancelInd = pCfgPort->lec;
			//mibVoiceServiceProfile.EchoCancelInd = pMibVoiceServiceProfile->EchoCancelInd;
		}

		/*Update to MIB*/
		MIB_Set(tableIndex, &mibVoiceServiceProfile, sizeof(mibVoiceServiceProfile));
    	break;
        #endif
    case MIB_DEL:
    	OMCI_LOG(OMCI_LOG_LEVEL_DBG,"VoiceServiceProfile --> DEL");
    	break;
    default:
    	break;
    }

    return GOS_OK;
}
GOS_ERROR_CODE mibTable_init(MIB_TABLE_INDEX tableId)
{
    gMibVoiceServiceProfileTableInfo.Name = "VoiceServiceProfile";
    gMibVoiceServiceProfileTableInfo.ShortName = "VSP";
    gMibVoiceServiceProfileTableInfo.Desc = "Voice service profile";
    gMibVoiceServiceProfileTableInfo.ClassId = (UINT32)(OMCI_ME_CLASS_VOICE_SRV_PROFILE);
    gMibVoiceServiceProfileTableInfo.InitType = (UINT32)(OMCI_ME_INIT_TYPE_OLT);
    gMibVoiceServiceProfileTableInfo.StdType = (UINT32)(OMCI_ME_TYPE_STANDARD);
    gMibVoiceServiceProfileTableInfo.ActionType = (UINT32)(OMCI_ME_ACTION_CREATE | OMCI_ME_ACTION_DELETE | OMCI_ME_ACTION_SET | OMCI_ME_ACTION_GET);
    gMibVoiceServiceProfileTableInfo.pAttributes = &(gMibVoiceServiceProfileAttrInfo[0]);

    gMibVoiceServiceProfileTableInfo.attrNum = MIB_TABLE_VOICESERVICEPROFILE_ATTR_NUM;
    gMibVoiceServiceProfileTableInfo.entrySize = sizeof(MIB_TABLE_VOICESERVICEPROFILE_T);
    gMibVoiceServiceProfileTableInfo.pDefaultRow = &gMibVoiceServiceProfileDefRow;

    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_ENTITYID_INDEX - MIB_TABLE_FIRST_INDEX].Name = "EntityId";
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_ANNOUNCEMENTTYPE_INDEX - MIB_TABLE_FIRST_INDEX].Name = "AnnouncementType";
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_JITTERTARGET_INDEX - MIB_TABLE_FIRST_INDEX].Name = "JitterTarget";
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_JITTERBUFFERMAX_INDEX - MIB_TABLE_FIRST_INDEX].Name = "JitterBufferMax";
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_ECHOCANCELIND_INDEX - MIB_TABLE_FIRST_INDEX].Name = "EchoCancelInd";
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_PSTNPROTOCOLVARIANT_INDEX - MIB_TABLE_FIRST_INDEX].Name = "PSTNProtocolVariant";
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_DTMFDIGITLEVELS_INDEX - MIB_TABLE_FIRST_INDEX].Name = "DTMFDigitLevels";
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_DTMFDIGITDURATION_INDEX - MIB_TABLE_FIRST_INDEX].Name = "DTMFDigitDuration";
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_HOOKFLASHMINIMUMTIME_INDEX - MIB_TABLE_FIRST_INDEX].Name = "HookFlashMinimumTime";
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_HOOKFLASHMAXIMUMTIME_INDEX - MIB_TABLE_FIRST_INDEX].Name = "HookFlashMaximumTime";
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_TONEPATTERNTABLE_INDEX - MIB_TABLE_FIRST_INDEX].Name = "TonePatternTable";
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_TONEEVENTTABLE_INDEX - MIB_TABLE_FIRST_INDEX].Name = "ToneEventTable";
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_RINGINGPATTERNTABLE_INDEX - MIB_TABLE_FIRST_INDEX].Name = "RingingPatternTable";
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_RINGINGEVENTTABLE_INDEX - MIB_TABLE_FIRST_INDEX].Name = "RingingEventTable";
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_NETWORKSPECIFICEXTENSIONSPOINTER_INDEX - MIB_TABLE_FIRST_INDEX].Name = "NetworkSpecificExtensionsPointer";

    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_ENTITYID_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "Entity ID";
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_ANNOUNCEMENTTYPE_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "Announcement type";
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_JITTERTARGET_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "Jitter target";
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_JITTERBUFFERMAX_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "Jitter buffer max";
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_ECHOCANCELIND_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "Echo cancel ind";
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_PSTNPROTOCOLVARIANT_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "PSTN protocol variant";
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_DTMFDIGITLEVELS_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "DTMF digit levels";
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_DTMFDIGITDURATION_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "DTMF digit duration";
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_HOOKFLASHMINIMUMTIME_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "Hook flash minimum time";
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_HOOKFLASHMAXIMUMTIME_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "Hook flash maximum time";
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_TONEPATTERNTABLE_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "Tone pattern table";
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_TONEEVENTTABLE_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "Tone Event table";
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_RINGINGPATTERNTABLE_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "Ringing pattern table";
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_RINGINGEVENTTABLE_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "Ringing Event table";
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_NETWORKSPECIFICEXTENSIONSPOINTER_INDEX - MIB_TABLE_FIRST_INDEX].Desc = "Network specific extensions pointer";

    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_ENTITYID_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT16;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_ANNOUNCEMENTTYPE_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT8;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_JITTERTARGET_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT16;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_JITTERBUFFERMAX_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT16;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_ECHOCANCELIND_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT8;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_PSTNPROTOCOLVARIANT_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT16;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_DTMFDIGITLEVELS_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT16;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_DTMFDIGITDURATION_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT16;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_HOOKFLASHMINIMUMTIME_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT16;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_HOOKFLASHMAXIMUMTIME_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT16;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_TONEPATTERNTABLE_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_TABLE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_TONEEVENTTABLE_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_TABLE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_RINGINGPATTERNTABLE_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_TABLE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_RINGINGEVENTTABLE_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_TABLE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_NETWORKSPECIFICEXTENSIONSPOINTER_INDEX - MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT16;

    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_ENTITYID_INDEX - MIB_TABLE_FIRST_INDEX].Len = 2;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_ANNOUNCEMENTTYPE_INDEX - MIB_TABLE_FIRST_INDEX].Len = 1;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_JITTERTARGET_INDEX - MIB_TABLE_FIRST_INDEX].Len = 2;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_JITTERBUFFERMAX_INDEX - MIB_TABLE_FIRST_INDEX].Len = 2;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_ECHOCANCELIND_INDEX - MIB_TABLE_FIRST_INDEX].Len = 1;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_PSTNPROTOCOLVARIANT_INDEX - MIB_TABLE_FIRST_INDEX].Len = 2;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_DTMFDIGITLEVELS_INDEX - MIB_TABLE_FIRST_INDEX].Len = 2;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_DTMFDIGITDURATION_INDEX - MIB_TABLE_FIRST_INDEX].Len = 2;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_HOOKFLASHMINIMUMTIME_INDEX - MIB_TABLE_FIRST_INDEX].Len = 2;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_HOOKFLASHMAXIMUMTIME_INDEX - MIB_TABLE_FIRST_INDEX].Len = 2;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_TONEPATTERNTABLE_INDEX - MIB_TABLE_FIRST_INDEX].Len = 20;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_TONEEVENTTABLE_INDEX - MIB_TABLE_FIRST_INDEX].Len = 7;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_RINGINGPATTERNTABLE_INDEX - MIB_TABLE_FIRST_INDEX].Len = 5;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_RINGINGEVENTTABLE_INDEX - MIB_TABLE_FIRST_INDEX].Len = 7;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_NETWORKSPECIFICEXTENSIONSPOINTER_INDEX - MIB_TABLE_FIRST_INDEX].Len = 2;

    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_ENTITYID_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = TRUE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_ANNOUNCEMENTTYPE_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_JITTERTARGET_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_JITTERBUFFERMAX_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_ECHOCANCELIND_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_PSTNPROTOCOLVARIANT_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_DTMFDIGITLEVELS_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_DTMFDIGITDURATION_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_HOOKFLASHMINIMUMTIME_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_HOOKFLASHMAXIMUMTIME_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_TONEPATTERNTABLE_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_TONEEVENTTABLE_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_RINGINGPATTERNTABLE_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_RINGINGEVENTTABLE_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_NETWORKSPECIFICEXTENSIONSPOINTER_INDEX - MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;

    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_ENTITYID_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = TRUE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_ANNOUNCEMENTTYPE_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = TRUE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_JITTERTARGET_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = TRUE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_JITTERBUFFERMAX_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = TRUE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_ECHOCANCELIND_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = TRUE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_PSTNPROTOCOLVARIANT_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = TRUE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_DTMFDIGITLEVELS_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = TRUE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_DTMFDIGITDURATION_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = TRUE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_HOOKFLASHMINIMUMTIME_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = TRUE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_HOOKFLASHMAXIMUMTIME_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = TRUE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_TONEPATTERNTABLE_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = TRUE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_TONEEVENTTABLE_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = TRUE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_RINGINGPATTERNTABLE_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = TRUE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_RINGINGEVENTTABLE_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = TRUE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_NETWORKSPECIFICEXTENSIONSPOINTER_INDEX - MIB_TABLE_FIRST_INDEX].MibSave = TRUE;

    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_ENTITYID_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_HEX;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_ANNOUNCEMENTTYPE_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_DEC;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_JITTERTARGET_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_DEC;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_JITTERBUFFERMAX_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_DEC;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_ECHOCANCELIND_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_DEC;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_PSTNPROTOCOLVARIANT_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_DEC;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_DTMFDIGITLEVELS_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_HEX;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_DTMFDIGITDURATION_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_DEC;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_HOOKFLASHMINIMUMTIME_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_DEC;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_HOOKFLASHMAXIMUMTIME_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_DEC;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_TONEPATTERNTABLE_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_HEX;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_TONEEVENTTABLE_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_HEX;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_RINGINGPATTERNTABLE_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_HEX;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_RINGINGEVENTTABLE_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_HEX;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_NETWORKSPECIFICEXTENSIONSPOINTER_INDEX - MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_HEX;

    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_ENTITYID_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ | OMCI_ME_ATTR_ACCESS_SBC;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_ANNOUNCEMENTTYPE_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ | OMCI_ME_ATTR_ACCESS_WRITE | OMCI_ME_ATTR_ACCESS_SBC;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_JITTERTARGET_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ | OMCI_ME_ATTR_ACCESS_WRITE | OMCI_ME_ATTR_ACCESS_SBC;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_JITTERBUFFERMAX_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ | OMCI_ME_ATTR_ACCESS_WRITE | OMCI_ME_ATTR_ACCESS_SBC;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_ECHOCANCELIND_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ | OMCI_ME_ATTR_ACCESS_WRITE | OMCI_ME_ATTR_ACCESS_SBC;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_PSTNPROTOCOLVARIANT_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ | OMCI_ME_ATTR_ACCESS_WRITE | OMCI_ME_ATTR_ACCESS_SBC;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_DTMFDIGITLEVELS_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ | OMCI_ME_ATTR_ACCESS_WRITE | OMCI_ME_ATTR_ACCESS_SBC;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_DTMFDIGITDURATION_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ | OMCI_ME_ATTR_ACCESS_WRITE | OMCI_ME_ATTR_ACCESS_SBC;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_HOOKFLASHMINIMUMTIME_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ | OMCI_ME_ATTR_ACCESS_WRITE | OMCI_ME_ATTR_ACCESS_SBC;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_HOOKFLASHMAXIMUMTIME_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ | OMCI_ME_ATTR_ACCESS_WRITE | OMCI_ME_ATTR_ACCESS_SBC;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_TONEPATTERNTABLE_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ | OMCI_ME_ATTR_ACCESS_WRITE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_TONEEVENTTABLE_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ | OMCI_ME_ATTR_ACCESS_WRITE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_RINGINGPATTERNTABLE_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ | OMCI_ME_ATTR_ACCESS_WRITE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_RINGINGEVENTTABLE_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ | OMCI_ME_ATTR_ACCESS_WRITE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_NETWORKSPECIFICEXTENSIONSPOINTER_INDEX - MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ | OMCI_ME_ATTR_ACCESS_WRITE | OMCI_ME_ATTR_ACCESS_SBC;

    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_ENTITYID_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_ANNOUNCEMENTTYPE_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_JITTERTARGET_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_JITTERBUFFERMAX_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_ECHOCANCELIND_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_PSTNPROTOCOLVARIANT_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_DTMFDIGITLEVELS_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_DTMFDIGITDURATION_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_HOOKFLASHMINIMUMTIME_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_HOOKFLASHMAXIMUMTIME_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_TONEPATTERNTABLE_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_TONEEVENTTABLE_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_RINGINGPATTERNTABLE_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_RINGINGEVENTTABLE_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_NETWORKSPECIFICEXTENSIONSPOINTER_INDEX - MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;

    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_ENTITYID_INDEX - MIB_TABLE_FIRST_INDEX].OptionType = OMCI_ME_ATTR_TYPE_MANDATORY;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_ANNOUNCEMENTTYPE_INDEX - MIB_TABLE_FIRST_INDEX].OptionType = OMCI_ME_ATTR_TYPE_MANDATORY;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_JITTERTARGET_INDEX - MIB_TABLE_FIRST_INDEX].OptionType = OMCI_ME_ATTR_TYPE_OPTIONAL;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_JITTERBUFFERMAX_INDEX - MIB_TABLE_FIRST_INDEX].OptionType = OMCI_ME_ATTR_TYPE_OPTIONAL;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_ECHOCANCELIND_INDEX - MIB_TABLE_FIRST_INDEX].OptionType = OMCI_ME_ATTR_TYPE_MANDATORY;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_PSTNPROTOCOLVARIANT_INDEX - MIB_TABLE_FIRST_INDEX].OptionType = OMCI_ME_ATTR_TYPE_OPTIONAL;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_DTMFDIGITLEVELS_INDEX - MIB_TABLE_FIRST_INDEX].OptionType = OMCI_ME_ATTR_TYPE_OPTIONAL;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_DTMFDIGITDURATION_INDEX - MIB_TABLE_FIRST_INDEX].OptionType = OMCI_ME_ATTR_TYPE_OPTIONAL;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_HOOKFLASHMINIMUMTIME_INDEX - MIB_TABLE_FIRST_INDEX].OptionType = OMCI_ME_ATTR_TYPE_OPTIONAL;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_HOOKFLASHMAXIMUMTIME_INDEX - MIB_TABLE_FIRST_INDEX].OptionType = OMCI_ME_ATTR_TYPE_OPTIONAL;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_TONEPATTERNTABLE_INDEX - MIB_TABLE_FIRST_INDEX].OptionType = OMCI_ME_ATTR_TYPE_OPTIONAL;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_TONEEVENTTABLE_INDEX - MIB_TABLE_FIRST_INDEX].OptionType = OMCI_ME_ATTR_TYPE_OPTIONAL;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_RINGINGPATTERNTABLE_INDEX - MIB_TABLE_FIRST_INDEX].OptionType = OMCI_ME_ATTR_TYPE_OPTIONAL;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_RINGINGEVENTTABLE_INDEX - MIB_TABLE_FIRST_INDEX].OptionType = OMCI_ME_ATTR_TYPE_OPTIONAL;
    gMibVoiceServiceProfileAttrInfo[MIB_TABLE_VOICESERVICEPROFILE_NETWORKSPECIFICEXTENSIONSPOINTER_INDEX - MIB_TABLE_FIRST_INDEX].OptionType = OMCI_ME_ATTR_TYPE_OPTIONAL;

    gMibVoiceServiceProfileDefRow.EntityId = 0;
    gMibVoiceServiceProfileDefRow.AnnouncementType = 0;
    gMibVoiceServiceProfileDefRow.JitterTarget = 0;
    gMibVoiceServiceProfileDefRow.JitterBufferMax = 0;
    gMibVoiceServiceProfileDefRow.EchoCancelInd = 10;
    gMibVoiceServiceProfileDefRow.PSTNProtocolVariant = 0;
    gMibVoiceServiceProfileDefRow.DTMFDigitLevels = 0x8000;
    gMibVoiceServiceProfileDefRow.DTMFDigitDuration = 0;
    gMibVoiceServiceProfileDefRow.HookFlashMinimumTime = 0;
    gMibVoiceServiceProfileDefRow.HookFlashMaximumTime = 0;
    memset(gMibVoiceServiceProfileDefRow.TonePatternTable, 0x00, 20);
    memset(gMibVoiceServiceProfileDefRow.ToneEventTable, 0x00, 7);
    memset(gMibVoiceServiceProfileDefRow.RingingPatternTable, 0x00, 5);
    memset(gMibVoiceServiceProfileDefRow.RingingEventTable, 0x00, 7);
    gMibVoiceServiceProfileDefRow.NetworkSpecificExtensionsPointer = 0xffff;

    memset(&gMibVoiceServiceProfileOper, 0x0, sizeof(MIB_TABLE_OPER_T));
    gMibVoiceServiceProfileOper.meOperDrvCfg = VoiceServiceProfileDrvCfg;
    gMibVoiceServiceProfileOper.meOperConnCheck = NULL;
    gMibVoiceServiceProfileOper.meOperDump = omci_mib_oper_dump_default_handler;
    gMibVoiceServiceProfileOper.meOperConnCfg = NULL;
    gMibVoiceServiceProfileOper.meOperAvlTreeAdd = NULL;
    gMibVoiceServiceProfileOper.meOperAlarmHandler = NULL;
    gMibVoiceServiceProfileOper.meOperTestHandler = NULL;

    MIB_TABLE_VOICESERVICEPROFILE_INDEX = tableId;
    MIB_InfoRegister(tableId, &gMibVoiceServiceProfileTableInfo, &gMibVoiceServiceProfileOper);
    MIB_RegisterCallback(tableId, NULL, NULL);

    return GOS_OK;
}

